<?php

class info{
	
	// Class Constructor
	public function __construct(){
		$this->db = new DBClass();
	}
	
	public function get_all_info(){
		
		$query = "Select * from artikel";
		$rows = $this->db->getRows($query);
		
		return $rows;
	}

	public function get_data(){
		$query = "select idadmin, username, fullname, email from admin 
			where username='".$_COOKIE['c_usr']."'";

		$rows = $this->db->getRows($query);

		return $rows[0];	
	}

	public function addInfo($data){
	$query ="INSERT INTO artikel SET artikel='".@$data['artikel']."',
	judul='".@$data['judul']."',
	tanggal='".@$data['tanggal']."'";

	$rows = $this->db->putRows($query);

	header('Location: info.php');
}
	public function hapusArtikel($data){
		
		$query ="DELETE FROM artikel WHERE judul='".@$data."'";

		$rows = $this->db->getRows($query);

		header('Location: info.php');
	}

}